<template>
  <div class="user-info">
    <p>用户信息</p>
    <el-form :model="userInfoForm" :label-width="labelWidth" class="user-form">
      <el-form-item label="用户">
        <el-input :disabled="disabledFlag" v-model="userInfoForm.name"></el-input>
      </el-form-item>
      <el-form-item label="密码">
        <el-input :disabled="disabledFlag" v-model="userInfoForm.password"></el-input>
      </el-form-item>
      <el-form-item label="手机号">
        <el-input :disabled="disabledFlag" v-model="userInfoForm.phoneNum"></el-input>
      </el-form-item>
      <el-form-item >
        <el-button @click="editHandle">编辑</el-button>
        <el-button v-if="!disabledFlag" @click="submitHandle">确定</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
  export default {
    name: 'UserInfo',
    data () {
      return {
        disabledFlag: true,
        labelWidth: '120px',
        userInfoForm: {
          name: '000',
          password: '',
          phoneNum: ''
        }
      }
    },
    methods: {
      editHandle () {
        this.disabledFlag = false;
      },
      submitHandle () {
        this.disabledFlag = true;
      }
    }
  }
</script>
<style scoped>
  .user-form {
    width: 500px;
    margin: 20px auto;
  }
</style>
